package com.hu.zhcc.shiro.controller;

import com.hu.zhcc.shiro.entity.tj.TCheckitem;
import com.hu.zhcc.shiro.entity.tj.TMember;
import com.hu.zhcc.shiro.entity.tj.TMemberExamination;
import com.hu.zhcc.shiro.entity.tj.TSetmeal;
import com.hu.zhcc.shiro.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/tjExamination")
public class TjTmeberExamination {
    @Autowired
    private TJ_TMemberService tjTMemberService;//会员表service层
    @Autowired
    private TJ_THealthmgrService tj_tHealthmgrService;//健康管理师
    @Autowired
    private Tj_TMemberDynamicinfoService tjTMemberDynamicinfoService;//会员动态表
    @Autowired
    private Tj_TMemberInfoService tj_tMemberInfoService;//会员详情表
    @Autowired
    private Tj_TMemberMedicalhistoryService tj_tMemberMedicalhistoryService;//会员病史表
    @Autowired
    private Tj_TCheckitemService tj_tCheckitemService;//检查项表
    @Autowired
    private TJ_TSetmealService tj_tSetmealService;//套餐表
    @Autowired
    private Tj_TMemberExaminationService tj_tMemberExaminationService;//会员检查表

    //查询会员表跟会员检查表
    @GetMapping("/queryTm")
    public List<TMemberExamination> queryTms(){
        System.out.println(tj_tMemberExaminationService.queryTm());
         return tj_tMemberExaminationService.queryTm();
    }

    //根据套餐表和检查项表 会员表的编号查询
    @GetMapping("/{id}")
    public TMemberExamination queryTE(@PathVariable("id") Integer id){
        TMember tMember = tjTMemberService.queryBytmemberId(id);
        TSetmeal tSetmeal = tj_tSetmealService.selectByPrimaryKey(id);
        TMemberExamination tMemberExamination=new TMemberExamination();
        TCheckitem tCheckitem = tj_tCheckitemService.queryByID(id);
        tMemberExamination.settCheckitem(tCheckitem);
        tMemberExamination.settMember(tMember);
        tMemberExamination.settSetmeal(tSetmeal);
        return tMemberExamination;
    }

}
